#include "music.h"

static char music_buf[128] = {0};				//拼接字符串buf

//1、播放音乐(指定播放)
int play_music(char *musicpath)
{
	bzero(music_buf, sizeof(music_buf));		//1、清空字符串
	sprintf(music_buf, "madplay -a 12 %s &", musicpath);	
												//2、拼接字符串于buf中
	system(music_buf);							//3、执行buf里面的shell命令
	return 0;
}


//2、结束音乐
int exit_music(void)
{
	system("killall -9 madplay &");
	return 0;
}

//3、暂停音乐
int stop_music(void)
{
	system("killall -STOP madplay &");
	return 0;
}

//4、继续音乐
int cont_music(void)
{
	system("killall -CONT madplay &");
	return 0;
}

//5、声音加大
int add_music(char *musicpath)
{
	system("killall -9 madplay");
	bzero(music_buf, sizeof(music_buf));		//1、清空字符串
	sprintf(music_buf, "madplay -a 12 %s &", musicpath);	
												//2、拼接字符串于buf中
	system(music_buf);							//3、执行buf里面的shell命令
	return 0;
}


//6、声音减小
int sub_music(char *musicpath)
{
	system("killall -9 madplay");
	bzero(music_buf, sizeof(music_buf));		//1、清空字符串
	sprintf(music_buf, "madplay -a 12 %s &", musicpath);	
												//2、拼接字符串于buf中
	system(music_buf);							//3、执行buf里面的shell命令
	return 0;
}


//7、单曲循环
int while_music(char *musicpath)
{
	system("killall -9 madplay");
	bzero(music_buf, sizeof(music_buf));		//1、清空字符串
	sprintf(music_buf, "madplay %s -r &", musicpath);	
												//2、拼接字符串于buf中
	system(music_buf);							//3、执行buf里面的shell命令
	return 0;
}


